<?php

class Progress {
    private $rowCount = 0;
    private $rowTotal = 0;
    private $prevPerc = 0;

    public function __construct($rowTotal) {
        $this->reset($rowTotal);
    }

    public function reset($rowTotal) {
        $this->rowCount = 0;
        $this->rowTotal = $rowTotal;
        $this->prevPerc = 0;
    }

    public function show() {
        $this->rowCount++;
        $rowPerc = round($this->rowCount / $this->rowTotal * 100);
        if ($this->prevPerc != $rowPerc) {
            echo $rowPerc . '% ';
            $this->prevPerc = $rowPerc;
            if ($this->prevPerc % 10 == 0) {
                echo "\n";
            }
        }
    }
}
